<%--
  Created by IntelliJ IDEA.
  User: Onlyevan
  Date: 2017/9/14
  Time: 14:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<html>
<head>
    <title>listCategory</title>
    <style type="text/css">
        div#insert{
            margin-top: 20px;
        }
    </style>
    <script src="js/jquery.min.js"></script>
    <script type="text/javascript">
        function delete1(id) {
            if (confirm("确定删除吗？")){
                location.href = "deleteCategory?id=" + id;
            }
        }
        $(function () {
            $("#insertcategory").click(function () {
                var name = $("#newname").val();
                location.href = "insertCategory?name=" + name;
            });
        });
    </script>
</head>
<body>
    <table align="center" border="1" cellspacing="0" width="25%">
        <tr>
            <td>id</td>
            <td>产品分类</td>
            <td>产品列表</td>
            <td>编辑</td>
            <td>删除</td>
        </tr>
        <c:forEach items="${listCategorys}" var="category">
            <tr>
                <td>${category.id}</td>
                <td>${category.name}</td>
                <td><a href="listProduct?id=${category.id}">产品列表</a></td>
                <td><a href="editCategory?id=${category.id}">编辑</a></td>
                <td><a href="javascript:void(0)" onclick="delete1(${category.id})">删除</a></td>
            </tr>
        </c:forEach>
    </table>
    <div align="center" style="margin-top: 20px">
        <a href="?start=0">首页</a>
        <a href="?start=${(pageSite.start - pageSite.count) < 0 ? 0 : pageSite.start - pageSite.count}">上一页</a>
        <c:forEach varStatus="num" items="${yeshu}">
            <a href="?start=${ (num.count - 1) * pageSite.count}">${num.count}</a>
        </c:forEach>
        <a href="?start=${(pageSite.start + pageSite.count) >= pageSite.end + pageSite.count ? pageSite.end : pageSite.start + pageSite.count}">下一页</a>
        <a href="?start=${pageSite.end}">尾页</a>
    </div>

    <div align="center" id="insert">
        分类名称：<input type="text" name="name" id="newname">
        <span><input type="button" value="增加分类" id="insertcategory"></span>
    </div>
</body>
</html>
